<template>
	<view>
		<u-button @click="scan">扫码</u-button>
		扫码内容:<u--text :text="str"></u--text>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				str: ""
			}
		},
		methods: {
			scan() {
				let that = this
				// 允许从相机和相册扫码
				uni.scanCode({
						success: function(res) {
							uni.setStorageSync("pilesId",res.result);
							uni.navigateTo({
								url: "/pages/view/scanResult/scanResult"
							})
							
							that.str = res.result;
						}
				});
		}
	},
	onShow() {
		let that = this;
		that.str = "";
	}
	}
</script>

<style>

</style>